import React, { useState } from 'react';
import sample2 from '../data/sample2';
import useGenFrozenColColumns from '../hooks/useGenFrozenColColumns';
import Table, { useRowClickSelection } from '../../../index';
function RowClickSelectTable(props) {
    const { rowKey } = props;
    const { rowSelection, onRowClick } = useRowClickSelection(rowKey);
    const [dataSource, setDataSource] = useState([]);
    const columns = useGenFrozenColColumns(sample2.columns);
    const fetchData = () => {
        console.log('run data fetch');
        return new Promise(resolve => { setDataSource(sample2.data); resolve({ total: dataSource.length }) })
    }
    return <Table
        {...props}
        columns={columns}
        dataSource={dataSource}
        fetchData={fetchData}
        rowSelection={
            { ...rowSelection }
        }
        onRow={(record) => {
            return {
                onClick: (e) => { onRowClick(e, record); }
            }
        }}
    />
}
export default RowClickSelectTable;